package com.zd.web.servlet;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zd.service.chapterAddWriterService;
import com.zd.service.impl.chapterAddWriterServiceImpl;

/**
 * Servlet implementation class chapterAddServlet
 */
@WebServlet("/chapterAddServlet")
public class chapterAddServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		String chapterName=request.getParameter("chapterName");
		int novelId= Integer.parseInt(request.getParameter("novelId"));
		String text=request.getParameter("chapterContents");
		Date date = new Date(System.currentTimeMillis());
		
		chapterAddWriterService caws= new chapterAddWriterServiceImpl();
		caws.chapterAddWriter(chapterName, novelId, text, date);
		
		request.getRequestDispatcher("fabucg.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
